// utils/config.js
// 应用配置管理

/**
 * 开发环境配置
 * 设置 isDevelopment = true 来启用模拟模式
 */
const isDevelopment = false // 🔧 改为 false 以使用真实API

/**
 * 环境配置
 */
const config = {
  // API配置
  api: {
    baseUrl: isDevelopment 
      ? 'mock://localhost'  // 模拟模式
      : 'http://10.108.165.49:8888', // 生产模式
    timeout: 10000,
    retryTimes: 3
  },
  
  // 功能开关
  features: {
    mockMode: isDevelopment,
    enableDebugLog: isDevelopment,
    skipPhoneVerification: isDevelopment,
    autoLogin: isDevelopment,
    // 认证相关配置
    skipAuthentication: true, // 🚫 暂时屏蔽用户认证
    bypassTokenCheck: true,   // 🚫 跳过Token验证
    skipLoginRedirect: true   // 🚫 跳过登录重定向
  },
  
  // WeChat小程序配置
  wechat: {
    skipRealAuth: isDevelopment, // 跳过真实微信认证
    mockUserProfile: isDevelopment
  },
  
  // 调试配置  
  debug: {
    showApiLogs: isDevelopment,
    showPerformanceLogs: isDevelopment,
    enableErrorReporting: !isDevelopment
  }
}

/**
 * 获取API基础URL
 */
const getApiBaseUrl = () => {
  return config.api.baseUrl
}

/**
 * 检查是否为开发模式
 */
const isDev = () => {
  return isDevelopment
}

/**
 * 检查是否为模拟模式
 */
const isMockMode = () => {
  return config.features.mockMode
}

/**
 * 检查是否跳过认证
 */
const shouldSkipAuthentication = () => {
  return config.features.skipAuthentication
}

/**
 * 检查是否跳过Token验证
 */
const shouldBypassTokenCheck = () => {
  return config.features.bypassTokenCheck
}

/**
 * 检查是否跳过登录重定向
 */
const shouldSkipLoginRedirect = () => {
  return config.features.skipLoginRedirect
}

/**
 * 获取完整配置
 */
const getConfig = () => {
  return config
}

module.exports = {
  config,
  isDevelopment,
  getApiBaseUrl,
  isDev,
  isMockMode,
  getConfig,
  shouldSkipAuthentication,
  shouldBypassTokenCheck,
  shouldSkipLoginRedirect
}